<?php
//error_reporting(1);
set_magic_quotes_runtime(0);

define('ROOT', dirname(__FILE__).'/');
mobile_define(ROOT.'config.php');

$classname = 'message';
$method = $_REQUEST['a'];
if(empty($classname) || empty($method)){
	die('no');
}

if(in_array($classname, array('message'))) {

	include ROOT."controller/base.php";
	include ROOT."controller/$classname.php";
	$control = new $classname();
	$data = $control->$method();
	echo is_array($data) ? $control->serialize($data, 1) : $data;
	exit;
	

} else {

	exit('Module not found!');

}
function writeLog()
{
	$args = func_get_args();
	//if(empty($args)) return false;
	$logFile = 'LogMessage.log';
	foreach ($args as $arg)
	{
		$content = is_array($arg) ? var_export($arg,true):$arg;
		file_put_contents($logFile, '['.date('m-d H:i:s',time()).']'.$content."\r\n",FILE_APPEND); 		
	}
}
function mobile_define($source)
{
    if (is_string($source))
    {
        /* 导入数组 */
        $source = include($source);
    }
    if (!is_array($source))
    {
        /* 不是数组，无法定义 */
        return false;
    }
    foreach ($source as $key => $value)
    {
        if (is_string($value) || is_numeric($value) || is_bool($value) || is_null($value))
        {
            /* 如果是可被定义的，则定义 */
            define(strtoupper($key), $value);
        }
    }
}